﻿@using Microsoft.AspNet.Identity
@{
    var returnUrl = Request.QueryString["returnUrl"] ?? Request.RawUrl;
}
@model IEnumerable<PaPaPa.Web.Models.Datings.DatingInfoViewModel>
@{
    ViewBag.Title = "约会大厅";
    Layout = "~/Areas/Basic/Views/Shared/_Layout.cshtml";
}

<div class="portlet light">
    <div class="popover-title">
        <div class="caption"><i class="glyphicon glyphicon-th-list color-green-sharp"></i> <span class="color-green-sharp">约会列表</span></div>
    </div>
@if (Request.IsAuthenticated)
    {
    <div class="form-horizontal">
        <table class="table table-hover datingtable">
            <tr class="success">
                <th>
                    @Html.DisplayNameFor(model => model.Name)
                </th>
                <th>
                    @Html.DisplayNameFor(model => model.DatingTime)
                </th>
                <th>
                    @Html.DisplayNameFor(model => model.Address)
                </th>
                <!-- todo 暂时因没有设计邀约环节屏蔽此处代码
                <th>
                    @Html.DisplayNameFor(model => model.InviteUser)
                </th>
                -->
                <th>
                    @Html.DisplayNameFor(model => model.Description)
                </th>
                <th>操作</th>
            </tr>

            @foreach (var item in Model)
            {
                <tr>
                    <td>
                        @Html.DisplayFor(modelItem => item.Name)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.DatingTime)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.Address)
                    </td>
                    <!-- todo 暂时因没有设计邀约环节屏蔽此处代码
                    <td>
                        @Html.DisplayFor(modelItem => item.InviteUser)
                    </td>
                    -->
                    <td>
                        @Html.DisplayFor(modelItem => item.Description)
                    </td>
                    <td>
                        <button type="button" onclick="AppDating(@Html.DisplayFor(modelItem => item.Id))" class="btn btn-link btn-xs">报名约会</button>
                    </td>
                </tr>
            }
        </table></div>
}
    else
    {
        <p>请先<a href="/User/Account/Login?returnUrl=@returnUrl">登录。</a></p>
    }
</div>
<script type="text/javascript">
    function AppDating(id) {
        $.ajax({
            type: 'post',
            url: 'AppDating',
            data: { datingId: id },
            success: function (result) { 
                if(result=="IsUser")
                {
                    alert("不能报名自己发布的约会啦！");
                }
                if(result=="Exist")
                {
                    alert("您已经报名这个约会了，别报啦！");
                }
                if(result=="success")
                {
                    alert("报名成功！");
                }
            }
        });
    }
</script>

